{% extends "blog/base.html" %}
<!-- 加载自定义标签 -->
{% load blog_tags %}

{% block content %} 
<h1>My Blog</h1>
{% if tag %} 
<h2>Posts tagged with "{{ tag.name }}"</h2> 
{% endif %} 
{% for post in posts %} 
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<p class="tags"> 
Tags: 
{% for tag in post.tags.all %} 
<!-- 每个标签都是一个链接，点击即可过滤含有此标签的文章进行显示 --> 
    <a href="{% url "blog:post_list_by_tag" tag.slug %}"> 
    {{ tag.name }} 
    </a > 
      {% if not forloop.last %}, {% endif %} 
  {% endfor %} 
  </p >
  <p class="date">Published {{ post.publish }} by {{ post.author }}</p > 
  <p>{{post.body|markdown|truncatewords_html:30}}</p > 
{% endfor %}
{% include "pagination.html" with page=posts %} 
{% endblock %}
